package com.yl.mytest;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.valence.safe.keyboard.SafeKeyboard;
import com.valence.safe.keyboard.SafeKeyboardConfig;


public class IncludeSameEditActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_include_same_edit);

        View includeViewTwo = findViewById(R.id.includeTwoLayout);

        EditText includeEditTwo = includeViewTwo.findViewById(R.id.normalEditText);

        View rootView = findViewById(R.id.includeRoot);             // 是 rootView
        View scrollView = findViewById(R.id.scrollViewLayout);      // 是 scrollView, 也可以是 rootView
        LinearLayout container = findViewById(R.id.safe_keyboard_place);

        Log.w(getClass().getSimpleName(), includeEditTwo.toString());
        Log.w(getClass().getSimpleName(), Integer.toHexString(System.identityHashCode(includeEditTwo)));

        Log.w(getClass().getSimpleName(), includeEditTwo.getId() + "");

        includeEditTwo.setText("");

        SafeKeyboardConfig config = SafeKeyboardConfig.getDefaultConfig();
        config.keyboardBgResId = R.color.transparent;
        SafeKeyboard safeKeyboard = new SafeKeyboard(getApplicationContext(), container, rootView, scrollView, config);
        safeKeyboard.setVibrateEnable(true);
        safeKeyboard.putRandomEdit(includeEditTwo);
    }
}